{extend name="../../admin/view/main"}

{block name='content'}

<div class="layui-card-header notselect">
    <span class="font-s10 color-desc margin-right-5"></span>
    <!--{if auth("record.car_record_remark/index")}-->
    <button class='layui-btn layui-btn-sm layui-btn-primary' data-modal="{:url('record.car_record_remark/index')}?record_id={$record_id}" style="float: right" data-width="90%">备注记录</button>
    <!--{/if}-->
</div>



<form action="{:url('remark')}" autocomplete="off" class="layui-form layui-card" data-auto="true" method="post">

    <div class="layui-col-xs12 relative block margin-top-10 margin-left-40">
        <label class="layui-form-item relative block">
            <span class="color-green font-w7 ">备注</span>
            <span class="color-desc margin-left-5">Remark</span>
            <textarea class="layui-textarea" name="remark" placeholder="请输入备注"></textarea>
        </label>
    </div>

    <div class="layui-col-xs12 relative block margin-top-10 margin-left-40">
        <span class="color-green font-w7 label-required-prev margin-left-10">原因分类</span>
        <br>
        <div class="layui-input-inline">
            <select class="layui-select layui-select-select" name="analyze_reason" lay-filter="analyze-reason">
                {foreach $analyzeReasons as $analyzeReasonId => $analyzeReason}
                    {if isset($analyze_reason) and $analyzeReasonId eq $analyze_reason}
                        <option selected value="{$analyzeReasonId}">{$analyzeReason}</option>
                    {else}
                        <option value="{$analyzeReasonId}">{$analyzeReason}</option>
                    {/if}
                {/foreach}
            </select>
        </div>
    </div>

    <div class="layui-col-xs12 relative block margin-top-10 margin-left-40">
        <label class="layui-form-item relative block">
            <span class="color-green font-w7">是否提醒</span>
            <span class="color-desc margin-left-5">NeedRemind</span>
            <br>
            {foreach [1 => '是', 0 => '否'] as $k=>$v}
            <input class="layui-radio" name="need_remind" title="{$v}" type="radio" value="{$k}" {if $v eq 0}checked{/if} lay-filter="need_remind">
            {/foreach}
        </label>
    </div>

    <div class="layui-col-xs12 relative margin-top-10 margin-left-40 remind_time_div">
        <label class="layui-form-item relative" style="display: none">
            <span class="color-green font-w7">提醒时间</span>
            <span class="color-desc margin-left-5">datetime</span>
            <input type="text" name="remind_at" class="layui-input" data-date-input="datetime">
        </label>
    </div>

    <div class="hr-line-dashed"></div>
    {notempty name='record_id'}<input name='record_id' type='hidden' value='{$record_id}'>{/notempty}

    <div class="layui-form-item text-center">
        <button class="layui-btn" type="submit">保存数据</button>
    </div>

</form>

<script>

    layui.use(['form'], function() {
    var form = layui.form;

    form.render();

    form.on('radio(need_remind)', function (data) {
        let el = $('.remind_time_div').find('.relative')
        if (data.value === '1') {
            el.addClass('block');
            el.show()
            form.render();
        } else {
           el.removeClass('block');
           el.hide();
            form.render();
        }

        // 使用 layui 的 form 模块重新渲染表单
        form.render();
    });
});

</script>
{/block}